Problem #1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(30 points) Define the following terms:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Problem #2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(10 points) Answer the following:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Problem #3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(20 points) Answer the following questions given the fsa: a) Identify which sentences are recognized by this automaton.
b) Show a left regular grammar that specifies the language recognized by the fsa. (Hint: write a grammar rule which would produce the fsa using the algorithm given in class.) c) Describe in English the language recognized by the fsa. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Problem #4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(20 points) Given the following LR parser tables and grammar rules, answer the following questions.
The grammar is
a) Show the parse tree for the sentence "( ( a ( a ) ) )". b) Show the parser configurations as it parses that input in the following table. You must use state numbers on the syntax stack. (Hint: 22 configurations are shown in the table -- the parse may take less than, more than, or equal to that number of steps.)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Problem #5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(20 points) Given the Java program fragments: C.java: package p; public class C { public int x; protected double y; private char z; public char getZ( ) { return z; } }D.java: package p; public class D extends C { String S; public void f( ) { S = ((Integer)x).toString( ); } }Hello.java: package p; public class Hello { public static void main(String[] args) { C ac = new C(); D ad = new D(); } } a) Which instance variables can be accessed using the object ac in the method main? b) Which instance variables can be accessed using the object ad in the method main? c) Which instance variables can be accessed in the method called by D.f() in the method main? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Total: 100 points |